package com.liuyu.common.framework.spring.beanpost;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @ClassName TestInstantiationAwareBeanPostProcessor
 * @Author: liuyu
 * @Date: Created in 2021/8/5 23:49
 * @Version: 1
 * @Modified By:
 */
@Component
@Slf4j
public class TestInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
        log.error("InstantiationAwareBeanPostProcessor postProcessBeforeInstantiation {},{}", beanClass, beanName);
        return InstantiationAwareBeanPostProcessor.super.postProcessBeforeInstantiation(beanClass, beanName);
    }

    @Override
    public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
        log.error("InstantiationAwareBeanPostProcessor postProcessAfterInstantiation {},{}", bean, beanName);
        return InstantiationAwareBeanPostProcessor.super.postProcessAfterInstantiation(bean, beanName);
    }
}
